package tasktracker.core.helper;

import java.util.Calendar;
import java.util.Date;

public class DateTimeHelper {

	public static Date getUtcDate() {
		Calendar cal = Calendar.getInstance();
		int zoneOffset = cal.get(Calendar.ZONE_OFFSET);
		int dstOffset = cal.get(Calendar.DST_OFFSET);
		cal.add(Calendar.MILLISECOND, -(zoneOffset + dstOffset));
		return cal.getTime();
	}

	public static Date utcDateToLocal(Date utcDate) {
		Calendar cal = Calendar.getInstance();
		int zoneOffset = cal.get(Calendar.ZONE_OFFSET);
		int dstOffset = cal.get(Calendar.DST_OFFSET);
		cal.setTime(utcDate);
		cal.add(Calendar.MILLISECOND, zoneOffset + dstOffset);
		return cal.getTime();
	}
}
